package br.urca.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "gradcur")
public class GradeCurso implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@EmbeddedId
	private GradeCursoPK id;
	
	@Column(name = "totcre")
	private int totalCreditos;
	
	@Column(name = "datres", columnDefinition = "DATETIME")
	@Temporal(TemporalType.TIMESTAMP)
	private Date datres; 
	
	@Column(name = "nures", columnDefinition = "VARCHAR(10)")
	private String nures;
	
	@Column(name = "texto", columnDefinition = "VARCHAR(16)")
	private String texto;
	
	@Column(name = "totcreaticomp")
	private int totalCredAtivCompl;
	
	@Column(name = "totcrepcc")
	private int totalCredPraticaCompCurr;
	
	public GradeCurso() { }

	public GradeCurso(GradeCursoPK id, int totalCreditos, Date datres,
			String nures, String texto, int totalCredAtivCompl,
			int totalCredPraticaCompCurr) {
		super();
		this.id = id;
		this.totalCreditos = totalCreditos;
		this.datres = datres;
		this.nures = nures;
		this.texto = texto;
		this.totalCredAtivCompl = totalCredAtivCompl;
		this.totalCredPraticaCompCurr = totalCredPraticaCompCurr;
	}

	public GradeCursoPK getId() {
		return id;
	}

	public void setId(GradeCursoPK id) {
		this.id = id;
	}

	public int getTotalCreditos() {
		return totalCreditos;
	}

	public void setTotalCreditos(int totalCreditos) {
		this.totalCreditos = totalCreditos;
	}

	public Date getDatres() {
		return datres;
	}

	public void setDatres(Date datres) {
		this.datres = datres;
	}

	public String getNures() {
		return nures;
	}

	public void setNures(String nures) {
		this.nures = nures;
	}

	public String getTexto() {
		return texto;
	}

	public void setTexto(String texto) {
		this.texto = texto;
	}

	public int getTotalCredAtivCompl() {
		return totalCredAtivCompl;
	}

	public void setTotalCredAtivCompl(int totalCredAtivCompl) {
		this.totalCredAtivCompl = totalCredAtivCompl;
	}

	public int getTotalCredPraticaCompCurr() {
		return totalCredPraticaCompCurr;
	}

	public void setTotalCredPraticaCompCurr(int totalCredPraticaCompCurr) {
		this.totalCredPraticaCompCurr = totalCredPraticaCompCurr;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((datres == null) ? 0 : datres.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((nures == null) ? 0 : nures.hashCode());
		result = prime * result + ((texto == null) ? 0 : texto.hashCode());
		result = prime * result + totalCredAtivCompl;
		result = prime * result + totalCredPraticaCompCurr;
		result = prime * result + totalCreditos;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		GradeCurso other = (GradeCurso) obj;
		if (datres == null) {
			if (other.datres != null)
				return false;
		} else if (!datres.equals(other.datres))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (nures == null) {
			if (other.nures != null)
				return false;
		} else if (!nures.equals(other.nures))
			return false;
		if (texto == null) {
			if (other.texto != null)
				return false;
		} else if (!texto.equals(other.texto))
			return false;
		if (totalCredAtivCompl != other.totalCredAtivCompl)
			return false;
		if (totalCredPraticaCompCurr != other.totalCredPraticaCompCurr)
			return false;
		if (totalCreditos != other.totalCreditos)
			return false;
		return true;
	}
	
}
